/*
 * @Author: yudun yudun@idata.ah.cn
 * @Date: 2025-09-28 11:25:41
 * @LastEditors: yudun yudun@idata.ah.cn
 * @LastEditTime: 2025-09-28 12:09:43
 * @FilePath: \trae-code\spzx-admin\src\main.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */

import { createApp } from 'vue'
import './style.css'
import App from './App.vue'
import router from './router/index'
import { pinia, useUserStore, useMenuStore } from './stores/index'

const app = createApp(App)
app.use(pinia)

// 在应用启动时加载用户信息和菜单
const userStore = useUserStore()
const menuStore = useMenuStore()
userStore.loadUserInfoFromStorage()
menuStore.loadMenusFromStorage()

// 如果用户已登录，从API获取最新的菜单数据
if (userStore.token) {
  menuStore.getAllMenus()
}

app.use(router)
app.mount('#app')